package com.example.basic.web.controller.warn;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.basic.core.result.Result;
import com.example.basic.core.result.ResultGenerator;
import com.example.basic.custom.Log;
import com.example.basic.web.model.warn.DepotWarn;
import com.example.basic.web.service.warn.DepotWarnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(value  = "储存安全报警", tags = {"储存安全报警"})
@RestController
@RequestMapping("/api/v1/byg/warn")
public class DepotWarnController {

    @Resource
    private DepotWarnService depotWarnService;

    @Log(title = "储存安全报警", description = "解除警报/取消解除 ")
    @ApiOperation(value = "解除警报/取消解除 ", notes = "解除警报/取消解除 ")
    @PostMapping("/releaseOrCancel")
    public Result<Integer> releaseOrCancel(@ApiParam(name = "id", value = "警报id") @RequestParam String id) {
        return ResultGenerator.genSuccessResult(depotWarnService.releaseOrCancel(id));
    }

    @Log(title = "储存安全报警", description = "列表")
    @ApiOperation(value = "列表", notes = "列表")
    @PostMapping("/queryList")
    public Result<IPage<DepotWarn>> queryList(
            @ApiParam(name = "pharmCode", value = "仓库编码 0-全部") @RequestParam(defaultValue = "0") String pharmCode,
            @ApiParam(name = "zoneCode", value = "分区编码 0-全部") @RequestParam(defaultValue = "0") String zoneCode,
            @ApiParam(name = "status", value = "状态 0-全部，1-未解除，2-已解除") @RequestParam(defaultValue = "0") String status,
            @ApiParam(name = "page", value = "页数，list分页的第几页") @RequestParam(defaultValue = "0") Integer page,
            @ApiParam(name = "size", value = "条数，list分页的每页条数") @RequestParam(defaultValue = "0") Integer size) {
        Page<DepotWarn> queryPage = new Page<>(page,size);
        return ResultGenerator.genSuccessResult(depotWarnService.queryList(queryPage,pharmCode, zoneCode,status));
    }
}
